home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 408_01 / snews.h < prev    next >
Text File  |  1993-08-06  |  7KB  |  205 lines

  1. /*
  2.     SNEWS 1.91
  3.  
  4.     Private decls for the SNEWS news reader
  5.  
  6.  
  7.     Copyright (C) 1991  John McCombs, Christchurch, NEW ZEALAND
  8.                         john@ahuriri.gen.nz
  9.                         PO Box 2708, Christchurch, NEW ZEALAND
  10.  
  11.     Modifications copyright (C) 1993  Daniel Fandrich
  12.                         <dan@fch.wimsey.bc.ca> or CompuServe 72365,306
  13.  
  14.     This program is free software; you can redistribute it and/or modify
  15.     it under the terms of the GNU General Public License, version 1, as
  16.     published by the Free Software Foundation.
  17.  
  18.     This program is distributed in the hope that it will be useful,
  19.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.     GNU General Public License for more details.
  22.  
  23.     See the file COPYING, which contains a copy of the GNU General
  24.     Public License.
  25.  
  26.  
  27.     Source is formatted with a tab size of 4.
  28.  
  29.  */
  30.  
  31. #include <alloc.h>
  32. #include <process.h>
  33. #include <io.h>
  34.  
  35.  
  36. /* #define INCLUDE_SIG */   /* enable this to have the reply function put */
  37.                             /* your sig on the reply - mail ususally does */
  38.                             /* this                                       */
  39.  
  40.  
  41.  
  42. #define ENTER               0x0D
  43. #define ESCAPE              0x1B
  44. #define TAB                 0x09
  45. #define BACKSP                0x08
  46.  
  47. #define LEFT                (0x4b << 8)
  48. #define RIGHT               (0x4d << 8)
  49. #define cLEFT               (0x73 << 8)
  50. #define cRIGHT              (0x74 << 8)
  51. #define Fn1                 (0x3b << 8)
  52. #define Fn2                 (0x3c << 8)
  53. #define Fn3                 (0x3d << 8)
  54. #define Fn4                 (0x3e << 8)
  55.  
  56. #define  UP_ARR             ('H' << 8)
  57. #define  DN_ARR             ('P' << 8)
  58. #define  PGUP               ('I' << 8)
  59. #define  PGDN               ('Q' << 8)
  60. #define  HOME               ('G' << 8)
  61. #define  END                ('O' << 8)
  62.  
  63. enum exit_codes {
  64.     EX_CONT,
  65.     EX_DUMMY,
  66.  
  67.     EX_PREVIOUS,
  68.     EX_PREVIOUS10,
  69.     EX_NEXT,
  70.     EX_NEXT10,
  71.     EX_NEXT_UNREAD,
  72.  
  73.     EX_DONE,
  74.     EX_QUIT
  75. };
  76.  
  77. #define TEXT_LINE           5
  78. #define PAGE_HEADER         5
  79. #define PAGE_LENGTH         19
  80.  
  81. /* if you change these see show_help */
  82. #define HELP_GROUP          0
  83. #define HELP_THREAD         1
  84. #define HELP_ARTICLES       2
  85.  
  86. /*
  87.  *  This structure allows the creation of linked list of article numbers
  88.  */
  89. typedef struct art_id {
  90.     long   id;                  /* article number                 */
  91.     long   art_off;             /* offset of the article          */
  92.     struct art_id *next_art;    /* pointer to next article number */
  93.     struct art_id *prev_art;    /* pointer to prev article number */
  94. } ART_ID;
  95.  
  96. /*
  97.  *  This structure is a doubly linked list of the unique article headers.  The
  98.  *  linked list of article numbers is built on 'art_num'.  This system
  99.  *  is allows flexible use of memory, but will get slower by n'ish
  100.  *  and there is a fair degree of allocation overhead in the ART_ID structure
  101.  *  But hey, it's simple
  102.  */
  103. typedef struct article {
  104.     char   header[63];          /* article header (subject)    */
  105.     int    num_articles;        /* number with this header     */
  106.     ART_ID *art_num;            /* pointer to list of articles */
  107.     struct article *next;       /* next topic                  */
  108.     struct article *last;       /* last topic                  */
  109.     int    index;               /* topic number from start     */
  110. } ARTICLE;
  111.  
  112.  
  113.  
  114.  
  115.  
  116. /*
  117.  *  This structure is a linked list of lines that make up an article. The
  118.  *  file is read in and the linked list is built
  119.  */
  120. typedef struct line {
  121.     char   *data;               /* pointer to line of text     */
  122.     struct line *next;          /* next line                   */
  123.     struct line *last;          /* last line                   */
  124.     int    index;               /* line number from start      */
  125. } LINE;
  126.  
  127.  
  128. /*
  129.  *  This structure is the handle for an article in RAM.  The file
  130.  *  is read in and the linked list built.
  131.  */
  132. /* These lengths don't propagate everywhere -- careful when changing them */
  133. #define WHO_LENGTH 70
  134. #define ORG_LENGTH 20
  135. #define MSG_ID_LENGTH 50
  136. typedef struct {
  137.     char  author[WHO_LENGTH];           /* truncated author              */
  138.     char  organisation[ORG_LENGTH];     /* truncated organisation        */
  139.     char  follow_up[80];      /* group for follow-up article             */
  140.     int   lines;              /* total lines in file                     */
  141.     LINE  *top;               /* points to start of article, incl header */
  142.     LINE  *start;             /* ponts to start of text                  */
  143. } TEXT;
  144.  
  145.  
  146. void select_code_page(void);
  147.  
  148. ACTIVE *select_group(ACTIVE *head, ACTIVE *current);
  149. void show_help(int h);
  150. void show_values(void);
  151. int read_group(ACTIVE *gp);
  152. void show_groups(ACTIVE **top, ACTIVE *this, int force);
  153. ARTICLE *get_headers(ACTIVE *gp);
  154. void eat_gunk(char *buf);
  155. void free_header(ARTICLE *start);
  156. ACTIVE *search_groups(ACTIVE *this);
  157.  
  158.  
  159. void show_threads(ACTIVE *gp, ARTICLE **top, ARTICLE *this, int force);
  160. void select_thread(ACTIVE *gp, ARTICLE *head);
  161. enum exit_codes read_thread(ACTIVE *gp, ARTICLE *this, ART_ID *first, int a_ct);
  162. ARTICLE *search_subjects(ARTICLE *this);
  163.  
  164. int count_unread_in_thread(ACTIVE *gp, ARTICLE *a);
  165. int count_unread_in_group(ACTIVE *gp);
  166. int mark_group_as_read(ACTIVE *gp);
  167.  
  168. void command(char *msg);
  169. void message(char *msg);
  170. void lmessage(char *msg);
  171.  
  172. TEXT *load_article(char *fnx, long offset);
  173. void free_article(TEXT *t);
  174.  
  175.  
  176. enum exit_codes read_article(ACTIVE *gp, TEXT *tx, char *subject, int a_ct, int of_ct);
  177. void show_article(ACTIVE *gp, TEXT *tx, char *subject, LINE *this, int a_ct,
  178.                   int of_ct);
  179. void show_percent(int percent);
  180. LINE *search_text(LINE *this);
  181.  
  182.  
  183. int save_to_disk(TEXT *tx, char *save_name, int mailbox);
  184. void reply_to_article(TEXT *tx, char *subject);
  185. void get_his_stuff(TEXT *tx, char *author, char *msg_id);
  186.  
  187.  
  188. void post(TEXT *tx, char *newsgroups, char *subject);
  189. void post_it(FILE *article, char *newsgroups, char *subject, char *dist,
  190.                   char *msg_id);
  191.  
  192. void rot13(TEXT *tx);
  193.  
  194. void expand_tabs(char *buf, int max_len);
  195.  
  196. int newsgroups_valid(char *ng);
  197.  
  198. void mail_to_someone(TEXT *tx);
  199.  
  200. void save_thread_to_disk(ACTIVE *gp, ARTICLE *this, char *save_name);
  201. void pipe_article(TEXT *tx, char *prog_name);
  202.  
  203. int get_any_key(void);
  204. char *stristr(char *str, char *sstr);
  205.